package com.qianfeng.shopping.util;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class GetTime {
    // 获取当前系统时间
    public  static String getNow(String pattern){
//        Date date = new Date();
//        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
//        String str = sdf.format(date);
//        return str;
        LocalDateTime time = LocalDateTime.now();
        // 格式转换
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);
        return time.format(dtf);
    }

    public static void main(String[] args) {
        String pattern="yyyy年MM月dd日 HH:mm:ss";
        System.out.println(getNow(pattern));

    }
}
